﻿
////////////////////////////////////////////////////////////////////////////////////////////
// 文件名: SysUserBLL.gen.cs
//
// 模块名称: SysUserBll
//
// 作者: LPC
//
// 历史记录（记录修改记录，修改文件后请添加修改记录，注明修改时间、修改人，修改内容）:
// 13-2-19    LPC    创建文件
////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Common;
using DAL;
using Model;

namespace BLL
{
    /// <summary>
    /// SysUser表业务逻辑层
    /// </summary>
    public class SysUserBLL //: BaseBLL
    {
        const string ErrorCodeSelect = "";    //查询异常编码
        const string ErrorCodeInsert = "";    //添加异常编码
        const string ErrorCodeUpdate = "";    //修改异常编码
        const string ErrorCodeDelete = "";    //删除异常编码
         
        /// <summary>
        /// 创建BLL对象
        /// </summary>
        /// <summary>
        /// 根据Guid字段获取SysUserInfo实体对象
        /// </summary>
        /// <param name="guid">Guid</param>
        /// <returns>SysUserInfo实体对象</returns>
        public static SysUserInfo GetInfoById(string guid)
        {
            try
            {
                return SysUserDAL.GetInfoById(guid);
            }
            catch (Exception ex)
            { 
                throw   ex;
            }
        }
        public static IFConfig GetIFInfoById(string id)
        {
            try
            {
                return SysUserDAL.GetIFInfoById(id);
            }
            catch (Exception ex)
            { 
                throw ex;
            }
        }
        public static UserIFConfig GetUserIFInfoById(string id)
        {
            try
            {
                return SysUserDAL.GetUserIFInfoById(id);
            }
            catch (Exception ex)
            { 
                throw ex;
            }
        }

        public static int ChangePassword(string userName, string password, string oldPwd)
        {
            return SysUserDAL.ChangePassword(userName, password, oldPwd);
        }

        public static string GetOldPwd(string userName)
        {
            return SysUserDAL.GetOldPwd(userName);
        }
        public List<string> GetUserColumnList()
        {
            return SysUserDAL.GetUserColumnList();
        }

        /// <summary>
        /// 往SysUser表内添加新记录
        /// </summary>
        /// <param name="sysUserInfo">SysUserInfo实体对象 </param>
        /// <returns>添加记录索引值</returns>
        public int Insert(SysUserInfo sysUserInfo)
        {
            try
            {
                return SysUserDAL.Insert(sysUserInfo);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "Insert", AppError.EROR, 0, ex, "添加SysUserBll信息出错。", null);
                return 0;
            }
        }
         
        public int UpdateUserIF(List<UserIFConfig> info, string modelID)
        {
            try
            {
                return SysUserDAL.UpdateUserIF(info, modelID);
            }
            catch (Exception ex)
            { 
                return 0;
            }
        }
        public int InsertUserIFColumn(UserIFColumnConfig info)
        {
            try
            {
                return SysUserDAL.InsertUserIFColumn(info);
            }
            catch (Exception ex)
            { 
                return 0;
            }
        }
        public int InsertIF(IFConfig info)
        {
            try
            {
                return SysUserDAL.InsertIF(info);
            }
            catch (Exception ex)
            { 
                return 0;
            }
        }
        public int UpdateIF(IFConfig info)
        {
            try
            {
                return SysUserDAL.UpdateIF(info);
            }
            catch (Exception ex)
            { 
                return 0;
            }
        }
        public int CheckUserName(string userName)
        {
            try
            {
                return SysUserDAL.CheckUserName(userName);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "Insert", AppError.EROR, 0, ex, "添加SysUserBll信息出错。", null);
                return 0;
            }
        }
        /// <summary>
        /// 更新SysUser表记录
        /// </summary>
        /// <param name="sysUserInfo">SysUserInfo实体对象</param>
        public int Update(SysUserInfo sysUserInfo)
        {
            try
            {
               return SysUserDAL.Update(sysUserInfo);
            }
            catch (Exception ex)
            { 
                throw ex;
            }
        }

        /// <summary>
        /// 根据Guid字段获取SysUserInfo实体对象
        /// </summary>
        /// <param name="guid">Guid</param>
        public int Delete(IDataParameter[] par)
        {
            try
            {
                return SysUserDAL.Delete(par);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "Delete", AppError.EROR, 0, ex, "删除SysUserBll信息出错。", "");
                throw new SystemException(ErrorCodeDelete, ex);
            }
        }
        public int DeleteIF(IDataParameter[] par)
        {
            try
            {
                return SysUserDAL.DeleteIF(par);
            }
            catch (Exception ex)
            { 
                throw ex;
            }
        }
        public int UpdateFunStatus(List<SqlParameter> par)
        {
            try
            {
                return SysUserDAL.UpdateFunStatus(par);
            }
            catch (Exception ex)
            { 
                throw ex;
            }
        }

        /// <summary>
        /// 获取SysUserInfo实体对象
        /// </summary> 
        public static IList<SysUserInfo> GetList(SqlParameter[] pare)
        {
            try
            {
                return SysUserDAL.GetList(pare);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取SysUserInfo实体对象
        /// </summary> 
        public IList<IFConfig> GetIFList(out int totalCount)
        {
            try
            {
                return new SysUserDAL().GetIFList(out totalCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string GetRTXSysName()
        {
            try
            {
                return new SysUserDAL().GetRTXSysName();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取SysUserInfo实体对象
        /// </summary> 
        public IList<UserIFConfig> GetUserIFList(string IFunName, string DBName, out int totalCount)
        {
            try
            {
                return new SysUserDAL().GetUserIFList(IFunName,DBName, out totalCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void UpdateState(IDataParameter[] paras)
        {
            try
            {
                SysUserDAL.UpdateState(paras);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "Delete", AppError.EROR, 0, ex, "删除SysUserBll信息出错。", "");
                throw new SystemException(ErrorCodeDelete, ex);
            }
        }


        public static bool GetDataByUsername(IDataParameter[] par)
        {
            try
            {
                return SysUserDAL.GetDataByUsername(par);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "GetInfo", AppError.EROR, 0, ex, "获取SysUserBll信息出错。",
                                "");
                throw new SystemException(ErrorCodeSelect, ex);
            }
        }

        public static List<Sys_RoleInfo> GetLogin(SqlParameter[] params1)
        {
            try
            {
                return SysUserDAL.GetLogin(params1);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysUserBLL", "GetInfo", AppError.EROR, 0, ex, "获取SysUserBll信息出错。",
                                "");
                return new List<Sys_RoleInfo>();
            }
        }

        #region SysUser

        public List<SysUserInfo> GetByUsernameWithOutId(string username, string guid=null)
        {
            var result = SysUserDAL.GetByUsernameWithOutId(username, guid);
            return result;
        }

        public static List<SysUserInfo> GetUserList(string EmployeeCode, string EmployeeName, string UserName, string expIDs
            , string order, string sort
            , string rows, string page, out int recordCount)
        {
            //SysUserDAL roleDal = new SysUserDAL();
            var result = SysUserDAL.GetUserList(EmployeeCode, EmployeeName, UserName, expIDs
            , order, sort
            , rows, page, out  recordCount);
            return result;
        }
        #endregion
    }
}